using System;
using System.IO;

namespace RevitForge.Services
{
    public class ApiKeySetService
    {
        private static readonly string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        private static readonly string SettingsPath = Path.Combine(AppDataPath, "RevitForge");
        private static readonly string ApiKeyPath = Path.Combine(SettingsPath, "apikey.config");

        public static string GetApiKey()
        {
            try
            {
                if (File.Exists(ApiKeyPath))
                {
                    return File.ReadAllText(ApiKeyPath);
                }
            }
            catch (Exception)
            {
                // 处理错误
            }
            return string.Empty;
        }

        public static void ShowApiKeySettings()
        {
            var window = new Views.ApiKeySetView();
            window.ShowDialog();
        }
    }
}